using AutoMapper;
using Common.Communal;
using ERP.Domain.Scheduling;
using MediatR;
using Scheduling.Api.Write.Application.Command.TeamMemberCommand;
using Scheduling.Services.TeamMembers;

namespace Scheduling.Api.Write.Application.CommandHandlers.TeamMemberHandler
{
    public class TeamMemberUpdCommandHandler : IRequestHandler<TeamMemberUpdCommand, ApiResult<int>>
    {
        public TeamMemberUpdCommandHandler(ITeamMemberServices teamMember, IMapper mapper)
        {
            TeamMember = teamMember;
            Mapper = mapper;
        }

        public ITeamMemberServices TeamMember { get; }
        public IMapper Mapper { get; }

        public async Task<ApiResult<int>> Handle(TeamMemberUpdCommand request, CancellationToken cancellationToken)
        {
            var list = Mapper.Map<TeamMember>(request);
            return await TeamMember.UpdTeamMember(list);
        }
    }
}







